<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.5"/>
<title>spi: xspi_intr_example.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="HTML_custom.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="xlogo_bg.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">spi
   </div>
   <div id="projectbrief">Vitis Drivers API Documentation</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.5 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Overview</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="globals.html"><span>APIs</span></a></li>
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="pages.html"><span>Examples</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('xspi__intr__example_8c.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">xspi_intr_example.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Overview</h2>
<div class="textblock"><p>This file contains a design example using the Spi driver (<a class="el" href="struct_x_spi.html" title="The XSpi driver instance data. ">XSpi</a>) and the Spi device using the interrupt mode. </p>
<p>This example works with a PPC/MicroBlaze processor.</p>
<dl class="section note"><dt>Note</dt><dd></dd></dl>
<p>None.</p>
<pre>
  MODIFICATION HISTORY:</pre><pre>  Ver   Who  Date     Changes
</p>
<hr/>
<p>
  1.01a sv   05/29/06 First release for Test App Integration
                      for Interrupt examples
  1.11a sdm  03/03/08 Minor changes to comply to Doxygen and coding guidelines
  3.00a ktn  10/22/09 Converted all register accesses to 32 bit access.
                      Updated to use the HAL APIs/macros. Replaced call to
                      XSpi_Initialize API with XSpi_LookupConfig and
                      XSpi_CfgInitialize.
  3.02a sdm  05/04/11 Updated to run the loopback test only in standard spi
                      mode.
  4.2   ms   01/23/17 Added xil_printf statement in main function to
                      ensure that "Successfully ran" and "Failed" strings
                      are available in all examples. This is a fix for
                      CR-965028.
  4.5   akm  07/12/19 Fixed compilation error by passing the correct interrupt
                      controller instance to <a class="el" href="xspi__intr__example_8c.html#abd314964daed3d1fb324ef61ed37f276" title="This function does a minimal test on the Spi device and driver as a design example. ">SpiIntrExample()</a> function.
  4.11  sb   07/11/23 Added support for system device-tree flow.
*</pre> </div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:abd314964daed3d1fb324ef61ed37f276"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xspi__intr__example_8c.html#abd314964daed3d1fb324ef61ed37f276">SpiIntrExample</a> (INTC *IntcInstancePtr, <a class="el" href="struct_x_spi.html">XSpi</a> *SpiInstancePtr, u16 SpiDeviceId, u16 SpiIntrId)</td></tr>
<tr class="memdesc:abd314964daed3d1fb324ef61ed37f276"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function does a minimal test on the Spi device and driver as a design example.  <a href="#abd314964daed3d1fb324ef61ed37f276">More...</a><br/></td></tr>
<tr class="separator:abd314964daed3d1fb324ef61ed37f276"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a60c82f8284908b74700875c6dadf9a49"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xspi__intr__example_8c.html#a60c82f8284908b74700875c6dadf9a49">SpiIntrHandler</a> (void *CallBackRef, u32 StatusEvent, u32 ByteCount)</td></tr>
<tr class="memdesc:a60c82f8284908b74700875c6dadf9a49"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function is the handler which performs processing for the SPI driver.  <a href="#a60c82f8284908b74700875c6dadf9a49">More...</a><br/></td></tr>
<tr class="separator:a60c82f8284908b74700875c6dadf9a49"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a840291bc02cba5474a4cb46a9b9566fe"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="xspi__intr__example_8c.html#a840291bc02cba5474a4cb46a9b9566fe">main</a> (void)</td></tr>
<tr class="memdesc:a840291bc02cba5474a4cb46a9b9566fe"><td class="mdescLeft">&#160;</td><td class="mdescRight">Main function to call the Spi interrupt example.  <a href="#a840291bc02cba5474a4cb46a9b9566fe">More...</a><br/></td></tr>
<tr class="separator:a840291bc02cba5474a4cb46a9b9566fe"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a840291bc02cba5474a4cb46a9b9566fe"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int main </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Main function to call the Spi interrupt example. </p>
<dl class="section return"><dt>Returns</dt><dd>XST_SUCCESS if successful, otherwise XST_FAILURE.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>None </dd></dl>

<p>References <a class="el" href="xspi__intr__example_8c.html#abd314964daed3d1fb324ef61ed37f276">SpiIntrExample()</a>.</p>

</div>
</div>
<a class="anchor" id="abd314964daed3d1fb324ef61ed37f276"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int SpiIntrExample </td>
          <td>(</td>
          <td class="paramtype">INTC *&#160;</td>
          <td class="paramname"><em>IntcInstancePtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="struct_x_spi.html">XSpi</a> *&#160;</td>
          <td class="paramname"><em>SpiInstancePtr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16&#160;</td>
          <td class="paramname"><em>SpiDeviceId</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16&#160;</td>
          <td class="paramname"><em>SpiIntrId</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function does a minimal test on the Spi device and driver as a design example. </p>
<p>The purpose of this function is to illustrate how to use the <a class="el" href="struct_x_spi.html" title="The XSpi driver instance data. ">XSpi</a> component using the interrupt mode.</p>
<p>This function sends data and expects to receive the same data.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">IntcInstancePtr</td><td>is a pointer to the instance of the INTC component. </td></tr>
    <tr><td class="paramname">SpiInstancePtr</td><td>is a pointer to the instance of Spi component. </td></tr>
    <tr><td class="paramname">SpiDeviceId</td><td>is the Device ID of the Spi Device and is the XPAR_&lt;SPI_instance&gt;_DEVICE_ID value from xparameters.h. </td></tr>
    <tr><td class="paramname">SpiIntrId</td><td>is the interrupt Id and is typically XPAR_&lt;INTC_instance&gt;_&lt;SPI_instance&gt;_VEC_ID value from xparameters.h .</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>XST_SUCCESS if successful, otherwise XST_FAILURE.</dd></dl>
<dl class="section note"><dt>Note</dt><dd></dd></dl>
<p>This function contains an infinite loop such that if interrupts are not working it may never return. </p>

<p>References <a class="el" href="struct_x_spi___config.html#a495ec19a4ab441ea59a0e220f0728dd9">XSpi_Config::BaseAddress</a>, <a class="el" href="xspi__intr__example_8c.html#a60c82f8284908b74700875c6dadf9a49">SpiIntrHandler()</a>, <a class="el" href="struct_x_spi.html#a9816437229050cd78cb29c4f762228b7">XSpi::SpiMode</a>, <a class="el" href="group__spi.html#gac2c043a14b04e38a61b1979ccaa8a200">XSP_MASTER_OPTION</a>, <a class="el" href="group__spi.html#ga858155b42d5a1da8efe06c9098e40b2d">XSpi_CfgInitialize()</a>, <a class="el" href="group__spi.html#gaf3863f11d27469d8797424319601c980">XSpi_InterruptHandler()</a>, <a class="el" href="group__spi.html#gac2c4a169e05ad6e040796ae86100fd5b">XSpi_LookupConfig()</a>, <a class="el" href="group__spi.html#ga11b6ebdb6f69c6939176e05600b10e3e">XSpi_SelfTest()</a>, <a class="el" href="group__spi.html#ga67c2076b133a55b6f80343642a1ace41">XSpi_SetOptions()</a>, <a class="el" href="group__spi.html#gabc09f4d503de2a772e5079ac46fc62b6">XSpi_SetStatusHandler()</a>, <a class="el" href="group__spi.html#ga87fdaad742a2669200c9b2617e5c86ea">XSpi_Start()</a>, and <a class="el" href="group__spi.html#ga4c44c082ef2d2b9cf4ba3db8bcebd954">XSpi_Transfer()</a>.</p>

<p>Referenced by <a class="el" href="xspi__intr__example_8c.html#a840291bc02cba5474a4cb46a9b9566fe">main()</a>.</p>

</div>
</div>
<a class="anchor" id="a60c82f8284908b74700875c6dadf9a49"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void SpiIntrHandler </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>CallBackRef</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u32&#160;</td>
          <td class="paramname"><em>StatusEvent</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u32&#160;</td>
          <td class="paramname"><em>ByteCount</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function is the handler which performs processing for the SPI driver. </p>
<p>It is called from an interrupt context such that the amount of processing performed should be minimized. It is called when a transfer of SPI data completes or an error occurs.</p>
<p>This handler provides an example of how to handle SPI interrupts and is application specific.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">CallBackRef</td><td>is the upper layer callback reference passed back when the callback function is invoked. </td></tr>
    <tr><td class="paramname">StatusEvent</td><td>is the event that just occurred. </td></tr>
    <tr><td class="paramname">ByteCount</td><td>is the number of bytes transferred up until the event occurred.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>None.</dd></dl>
<dl class="section note"><dt>Note</dt><dd>None. </dd></dl>

<p>Referenced by <a class="el" href="xspi__intr__example_8c.html#abd314964daed3d1fb324ef61ed37f276">SpiIntrExample()</a>.</p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
	<p class="footer">&copy; Copyright 2015-2022 Xilinx, Inc. All Rights Reserved.</p>
	<p class="footer">&copy; Copyright 2022-2023 Advanced Micro Devices, Inc. All Rights Reserved.</p>
</div>
</body>
</html>
